<template>
    <el-cascader
        :placeholder="props.placeholder"
        :options="props.options"
        v-model="tinymceData"
        :props="{
                                  value: 'name',
                                  label: 'value',
                                  children: 'children',
                                  expandTrigger: 'hover' }"
        
        @change="handleFaultChange"
    />
</template>

<script lang='ts' setup>


const props = withDefaults(defineProps<{
        modelValue?: any
        placeholder?: string
        options?: any
        value1?: string
        value2?: string
    }>(),
    
    {
        modelValue: () => [],
        placeholder: "请选择",
        options: ""
    })

const tinymceData = ref(props.modelValue)


/**
 * 修改的值
 *
 * @author 徐寿春
 * 2023/4/25 09:35
 */
function handleFaultChange(value: string[]) {
    emits("change", value)
}


let emits = defineEmits(["change", "update:modelValue" ,"update:value1","update:value2"]);
watch(() => tinymceData.value, (data) => {
    emits('update:modelValue', data)
    emits('update:value1', data[0])
    emits('update:value2', data[1])
})

</script>

